<script lang="ts" setup>
import { onLaunch, onShow } from '@dcloudio/uni-app';
import { state as globalState } from '@/store/global';
import getOrders from '@/vendor/order_food/order';
const { updateStatus } = getOrders();
// import { state as socketState } from './store/imStore';
onLaunch(() => {
	initSetting();
});

onShow((options: any) => {
	console.log(options)
	if (options.path == 'pages/tabbar/orders' && options.referrerInfo && options.referrerInfo.extraData) {
		if (options.referrerInfo.extraData.status == 'success') {
			// 收货成功
			console.log(globalState.conmfirmOrder);
			updateStatus(globalState.conmfirmOrder.inner_trade_no, 6, (res) => {
				console.log("确认收货回调....")
				console.log(res)
				if (res.msg == '成功') {
					globalState.conmfirmOrder.status = 6;
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
				}
			});
		}
	}
});

// onUnload(()=>{
// 	socketState.fd = "" // 置空
// })

const initSetting = () => {
	// 微信获取授权
	// #ifdef MP-WEIXIN
	uni.getSetting({
		success(res) {
			if (!res.authSetting['scope.userLocation']) {
				// 地理位置
				uni.authorize({
					scope: 'scope.userLocation'
				});
			}
		}
	});
	// #endif
};
</script>

<style lang="scss">
/*每个页面公共css */
@import '@/static/iconfont.css';
@import '@/styles/app.scss';
.parent {
	min-height: 100vh;
	padding: 15px;
	position: relative;
}
</style>
